package com.zhentao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.aliyun.TextModerationPlusUtil;
import com.zhentao.common.dtos.PageResponseResult;
import com.zhentao.common.dtos.ResponseResult;
import com.zhentao.common.enums.AppHttpCodeEnum;
import com.zhentao.constants.UserThreadLocal;
import com.zhentao.dating.domain.ApSocialCircle;
import com.zhentao.dating.dto.DatingDtoPage;
import com.zhentao.service.ApSocialCircleService;
import com.zhentao.mapper.ApSocialCircleMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author 86188
* @description 针对表【ap_social_circle】的数据库操作Service实现
* @createDate 2024-08-31 11:33:15
*/
@Service
@Slf4j
public class ApSocialCircleServiceImpl extends ServiceImpl<ApSocialCircleMapper, ApSocialCircle>
    implements ApSocialCircleService{
    @Autowired
    private ApSocialCircleMapper apSocialCircleMapper;
    @Override
    public ResponseResult indexDatingList(DatingDtoPage dto) {
        dto.checkParam();
       List<ApSocialCircle> list = apSocialCircleMapper.listSocialUser(dto);
        return null;
    }

    @Override
    public ResponseResult publishSocial(ApSocialCircle socialCircle) {
        ResponseResult result = TextModerationPlusUtil.checkContent(socialCircle.getContent());
        if(result.getCode() == 200){
            log.info("审核成功: {}",socialCircle.getContent());
            socialCircle.setPostingTime(new Date());
            socialCircle.setUserId(UserThreadLocal.getUserInfo().getId());
            save(socialCircle);
        }
        else if (result.getCode()== 600){
            log.info("审核失败: {}",socialCircle.getContent());
            return ResponseResult.errorResult(400,"内容审核不通过");
        }
        else if (result.getCode() ==601){
            log.info("审核中: {}",socialCircle.getContent());
            return ResponseResult.errorResult(400,"内容审核中");
        }
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }
}




